PostgreSQL将1分钟OHLCV烛光数据重采样为5分钟OHLCV烛光数据

您所在的位置:网站首页 10分钟 pandas PostgreSQL将1分钟OHLCV烛光数据重采样为5分钟OHLCV烛光数据

PostgreSQL将1分钟OHLCV烛光数据重采样为5分钟OHLCV烛光数据

2023-03-24 19:34| 来源: 网络整理| 查看: 265

我有一个PostgreSQL数据库,其中包含以下列:

timestamp - Unix timestamp in milliseconds open - The first traded price high - The highest traded price low - THe lowest traded price close - The last traded price volume - The total volumed transacted during the time period

有时我会查询30天以上的数据(43.2k行)。这些查询需要很长时间,所以我想每当我有〉30天的数据时,我会获取5分钟蜡烛,而不是将行数减少5倍。基本上,我正在寻找一个函数来实现这一点(伪代码):

SELECT first_value(timestamp), first_value(open), max(high), min(low), last_value(close), sum(volume) WHERE timestamp > {some timestamp in the past} AND timestamp < {current time} GROUP BY floor((timestamp / 1000) / (60*5)) * 5 ORDER BY timestamp

任何帮助都将不胜感激,我在这件事上耽搁了一段时间



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3